local SheildInst = class("SheildInst")
local GameUtils = require("utils.GameUtils")
local Vector3 = require("utils.Vector3")

function SheildInst:ctor(config, actor)
    self._config = config
    self._actor = actor
    local gameObject = GameUtils.InstantiateEmptyObject(self._config.name)
    local luaBehaviour = gameObject:AddComponent(typeof(CS.LuaBehaviour))
    luaBehaviour:SetScriptEnv(self)
    self._count = 1
end

function SheildInst:increaseCount()
    self._count = self._count + 1
end

function SheildInst:decreaseCount()
    self._count = self._count - 1
end

function SheildInst:getCount()
    return self._count
end

function SheildInst:start()
    local effect = G_ResourceManager:loadBuff(self._config.res)
    local gameObject = GameUtils.instantiateTo(self.transform, effect)
    gameObject.transform.localPosition = Vector3.new(0, 0, 0)
    gameObject.transform.localScale = Vector3.new(1, 1, 1)
end

function SheildInst:remove()
    GameUtils.destroy(self.gameObject)
end

return SheildInst
